package testcases;
import java.util.Date;

import juf.Annotations.CustomAdapter;
import juf.Annotations.Name;

/**
 * 
 */

/**A simple test class for JUF
 * 
 * ---------------------------------------------------------------------------------------
 * 
 * Please do not modify attributes of this class without making sure your 
 * changes doesn't affect the test cases, some of them use this class as a fixture.
 * 
 * ---------------------------------------------------------------------------------------
 * 
 * POJO representing a student that JUF should be able to interpret via reflection
 * and construct an interface for on-the-fly
 * 
 * <p> <hr>
 * <b>from Wikipedia:</b><p>
 * As of November 2005, the term "POJO" is mainly used to denote a Java object which 
 * does not follow any of the (major) Java object models, conventions, or frameworks such as EJB.
 * <p>
 * Ideally speaking, a POJO is a Java object not bound by any restriction other than those forced 
 * by the Java Language Specification. I.e., a POJO should not have to:<br>

 * <ol><li>Extend prespecified classes, as in <br><code>public class Foo extends javax.servlet.http.HttpServlet { ...</code>
 *  <li>Implement prespecified interfaces, as in <br><code>public class Bar implements javax.ejb.EntityBean { ...</code>
 *  <li>Contain prespecified annotations, as in <br><code>@javax.ejb.Entity public class Baz{ ...</code>
 *  </ol><p>
 * However, due to technical difficulties and other reasons, many software products or 
 * frameworks described as POJO-compliant actually still require the use of prespecified 
 * annotations for features such as persistence to work properly.
 * <hr>
 * 
 * @author Dale Halliwell, Parul Sharma
 *
 */
public class Student implements Cloneable {

	//some private members
	@juf.Annotations.Name("First Name")
	public String firstname;
	private String lastname;
	private Date dateofbirth;
	public int studentId;
	public boolean male;
	private String collegename;
	@CustomAdapter("JListAdapter")
	public Student[] friends = new Student[2];
	public Student bestFriend;
	public Paper favoritePaper;
	private double fine;
	public float gpa;
	@Name("Tree Demo")
	public Object[] hierarchy;
	//private String notes;
	
	public Student(int studentID, String firstname, String lastname, Date dateofbirth, boolean male, double fine){
		this.studentId = studentID;
		this.firstname= firstname;
		this.lastname = lastname;
		this.dateofbirth = dateofbirth;
		this.male = male;
		this.fine = 30.00;
		this.collegename ="Sciences";
		this.favoritePaper = new Paper("159.407 Object-Oriented Software Engineering");
		this.hierarchy = ExampleGenerator.classHierarchy();
	}
	
	@Override
	public String toString(){
		return firstname + " " + lastname;		
	}
	
	//public accessors 
	

	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}
	
	@juf.Annotations.Name("First Name")
	@juf.Annotations.Order(3)
	public String getFirstname() {
		return firstname;
	}
	
	
	public void setLastname(String lastname) {
		this.lastname = lastname;
	}
	
	//@juf.Annotations.Order(2)
	@juf.Annotations.Name("Last Name")
	public String getLastname() {
		return lastname;
	}
		
	public void setDateofbirth(Date dateofbirth) {
		this.dateofbirth = dateofbirth;
	}
	
	@juf.Annotations.Order(1)
	@juf.Annotations.Name("Date of Birth")
	public Date getDateofbirth() {
		return dateofbirth;
	}
	
	@juf.Annotations.Name("ID")
	@juf.Annotations.Attributes(setColumns=5)
	//student id should be read-only
	public int getStudentId() {
		return studentId;
	}

	@juf.Annotations.Name("Male?")
	public boolean isMale() {
		return male;
	}

	//readonly
	public String getCollegename() {
		return collegename;
	}
	
	
	
	public void setFine(double fine) {
		this.fine = fine;
	}
	
	@juf.Annotations.Attributes(setForeground = "255, 0, 0")
	@juf.Annotations.Name("Fine $")
	public double getFine() {
		return fine;
	}
	
    public Object clone() {
        try {
        	System.out.println("Cloned: " + this.toString());
            return super.clone();
        }
        catch (CloneNotSupportedException e) {
            throw new InternalError(e.toString());
        }
    }

	
	
}
